<%--
  Created by IntelliJ IDEA.
  User: 18902
  Date: 2020/10/19
  Time: 22:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%--<%@ taglib prefix="itheima" uri="http://com.sushe/common/"%>--%>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName()
            + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
    <meta name="referrer" content="no-referrer">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>宿舍管理系统--学生界面</title>
    <!-- 引入css样式文件 -->
    <!-- Bootstrap Core CSS -->
    <link href="${pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet" />
    <!-- MetisMenu CSS -->
    <link href="${pageContext.request.contextPath }/css/metisMenu.min.css" rel="stylesheet" />
    <!-- DataTables CSS -->
    <link href="${pageContext.request.contextPath }/css/dataTables.bootstrap.css" rel="stylesheet" />
    <!-- Custom CSS -->
    <link href="${pageContext.request.contextPath }/css/sb-admin-2.css" rel="stylesheet" />
    <!-- Custom Fonts -->
    <link href="${pageContext.request.contextPath }/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath }/css/boot-crm.css" rel="stylesheet" type="text/css" />
</head>
<body class="shouye">
<div id="wrapper" class="shouye">
    <!-- 导航栏部分 -->
    <nav class="navbar navbar-default navbar-static-top" role="navigation"
         style="margin-bottom: 0">
        <div class="navbar-header">
            <a class="navbar-brand" style="font-size: 30px">宿舍管理系统 v1.0</a>
        </div>
        <!-- 导航栏右侧图标部分 -->
        <ul class="nav navbar-top-links navbar-right">
            <!-- 邮件通知 start -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fa fa-envelope fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-messages">
                    <li>
                        <a href="#">
                            <div>
                                <strong>张经理</strong> <span class="pull-right text-muted">
								<em>昨天</em>
							</span>
                            </div>
                            <div>今天晚上开会，讨论一下下个月工作的事...</div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a class="text-center" href="#">
                            <strong>查看全部消息</strong>
                            <i class="fa fa-angle-right"></i>
                        </a>
                    </li>
                </ul>
            </li>
            <!-- 邮件通知 end -->
            <!-- 任务通知 start -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fa fa-tasks fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-tasks">
                    <li>
                        <a href="#">
                            <div>
                                <p>
                                    <strong>任务 1</strong>
                                    <span class="pull-right text-muted">完成40%</span>
                                </p>
                                <div class="progress progress-striped active">
                                    <div class="progress-bar progress-bar-success"
                                         role="progressbar" aria-valuenow="40" aria-valuemin="0"
                                         aria-valuemax="100" style="width: 40%">
                                        <span class="sr-only">完成40%</span>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="#">
                            <div>
                                <p>
                                    <strong>任务 2</strong>
                                    <span class="pull-right text-muted">完成20%</span>
                                </p>
                                <div class="progress progress-striped active">
                                    <div class="progress-bar progress-bar-info" role="progressbar"
                                         aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"
                                         style="width: 20%">
                                        <span class="sr-only">完成20%</span>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a class="text-center" href="#">
                            <strong>查看所有任务</strong>
                            <i class="fa fa-angle-right"></i>
                        </a>
                    </li>
                </ul>
            </li>
            <!-- 任务通知 end -->
            <!-- 消息通知 start -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fa fa-bell fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-alerts">
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-comment fa-fw"></i> 新回复
                                <span class="pull-right text-muted small">4分钟之前</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-envelope fa-fw"></i> 新消息
                                <span class="pull-right text-muted small">4分钟之前</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-tasks fa-fw"></i> 新任务
                                <span class="pull-right text-muted small">4分钟之前</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="#">
                            <div>
                                <i class="fa fa-upload fa-fw"></i> 服务器重启
                                <span class="pull-right text-muted small">4分钟之前</span>
                            </div>
                        </a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a class="text-center" href="#">
                            <strong>查看所有提醒</strong>
                            <i class="fa fa-angle-right"></i>
                        </a>
                    </li>
                </ul>
            </li>
            <!-- 消息通知 end -->
            <!-- 用户信息和系统设置 start -->
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fa fa-user fa-fw"></i>
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li><a href="#"><i class="fa fa-user fa-fw"></i>
                        用户：${USER_SESSION.username}
                    </a>
                    </li>
                    <li><a href="#"><i class="fa fa-gear fa-fw"></i> 系统设置</a></li>
                    <li class="divider"></li>
                    <li>
                        <a href="${pageContext.request.contextPath }/logout.action">
                            <i class="fa fa-sign-out fa-fw"></i>退出登录
                        </a>
                    </li>
                </ul>
            </li>
            <!-- 用户信息和系统设置结束 -->
        </ul>
        <!-- 左侧显示列表部分 start-->
        <div class="navbar-default sidebar" role="navigation">
            <div class="sidebar-nav navbar-collapse">
                <br/><br/>
                <ul class="nav" id="side-menu" style="font-size: 18px">
                    <li>
                        <a href="javascript:;" class="active">
                            <i class="fa fa-edit fa-fw"></i> 个人信息列表
                        </a>
                        <ul class="sub-menu">
                            <li>
                                <a href="info_list.jsp">
                                    <cite>个人信息</cite>
                                </a>
                            </li >
                        </ul>
                    </li>
                    <li>
                        <a href="javascript:;" class="active">
                            <i class="fa fa-edit fa-fw"></i> 公告列表
                        </a>
                        <ul class="sub-menu">
                            <li>
                                <a href="${pageContext.request.contextPath }/findGongGao.action">
                                    <cite>公告信息</cite>
                                </a>
                            </li >
                        </ul>
                    </li>
                    <li>
                        <a href="javascript:;" class="active">
                            <i class="fa fa-edit fa-fw"></i> 学生列表
                        </a>
                        <ul class="sub-menu">
                            <li>
                                <a href="${pageContext.request.contextPath }/student/allList.action">
                                    <cite>学生信息</cite>
                                </a>
                            </li >
                        </ul>
                    </li>
                    <li>
                        <a href="javascript:;">
                            <i class="fa fa-dashboard fa-fw" ></i> 宿舍列表
                        </a>
                        <ul class="sub-menu">
                            <li>
                                <a href="${pageContext.request.contextPath }/findSuSheStudent.action">
                                    <cite>宿舍信息</cite>
                                </a>
                            </li >
                        </ul>
                        <ul class="sub-menu">
                            <li>
                                <a href="/findSuSheRepair">
                                    <cite>维修登记</cite>
                                </a>
                            </li >
                        </ul>
                    </li>
                    <li>
                        <a href="javascript:;" class="active">
                            <i class="fa fa-edit fa-fw"></i> 访客列表
                        </a>
                        <ul class="sub-menu">
                            <li>
                                <a href="${pageContext.request.contextPath }/findVisitor.action">
                                    <cite>访客信息</cite>
                                </a>
                            </li >
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <!-- 左侧显示列表部分 end-->
    </nav>
    <!-- 首页展示个人信息部分  start-->
    <div id="page-wrapper" style="width: 80%;height: 94%">
        <div class="row" >
            <div class="col-lg-12">
                <h3 class="page-header" align="center">${USER_SESSION.username}，欢迎来到宿舍管理系统！<br/><br/></h3>
            </div>
            <div align="center" style="width: 100%">
                <table border="1" width="300px">
                    <tr>
                        <td><label style="font-size: 20px;align-content: center" >个人信息</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">编号：${USER_SESSION.userid}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">账户：${USER_SESSION.useracount}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">密码：${USER_SESSION.password}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">姓名：${USER_SESSION.username}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">角色：${USER_SESSION.userrole}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">权限：${USER_SESSION.userpower}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">年龄：${USER_SESSION.age}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">电话：${USER_SESSION.phone}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">地址：${USER_SESSION.address}</label></td>
                    </tr>
                    <tr>
                        <td><label style="font-size: 15px">现在所在城市：${USER_SESSION.city}</label></td><br/>
                    </tr>
                </table>
                <br/><br/>
            </div>
            <div align="center">
                <label><a href="#" style="width: 100px;height: 33px;background-color: #9be;font-size: 16px" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#userEditDialog" onclick= "editUser(${USER_SESSION.userid})">修改信息</a></label>
                <br/><br/><br/>
                <div class="footer">
                    <center>
                        <div class="copyright">Copyright ©2020-2021 版权所有</div>
                    </center>
                </div>
            </div>
        </div>
    </div>
    <!-- 部分  end-->
</div>
<div class="modal fade" id="userEditDialog" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">修改个人信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="edit_user_form">
                    <input type="hidden" id="userid" name="userid"/>
                    <div class="form-group">
                        <label for="useracount" class="col-sm-2 control-label">账号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="useracount" placeholder="账号" name="useracount" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="password" class="col-sm-2 control-label">密码</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="password" placeholder="密码" name="password" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">姓名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="username" placeholder="姓名" name="username" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="userrole" class="col-sm-2 control-label">角色</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="userrole" placeholder="角色" name="userrole" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="userpower" class="col-sm-2 control-label">权限</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="userpower" placeholder="权限" name="userpower" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="age" class="col-sm-2 control-label">年龄</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="age" placeholder="年龄" name="age" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="phone" class="col-sm-2 control-label">电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="phone" placeholder="电话" name="phone" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="address" class="col-sm-2 control-label">地址</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="address" placeholder="地址" name="address" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="city" class="col-sm-2 control-label">所在城市</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="city" placeholder="所在城市" name="city" />
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="updateUser()">保存修改</button>
            </div>
        </div>
    </div>
</div>
<!-- 引入js文件 -->
<!-- jQuery -->
<script src="${pageContext.request.contextPath }/js/jquery-1.11.3.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="${pageContext.request.contextPath }/js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="${pageContext.request.contextPath }/js/jquery.dataTables.min.js"></script>
<script src="${pageContext.request.contextPath }/js/dataTables.bootstrap.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="${pageContext.request.contextPath }/js/sb-admin-2.js"></script>
<!-- 编写js代码 -->
<script type="text/javascript">
    // 通过id获取修改的客户信息
    function editUser(id) {
        $.ajax({
            type:"get",
            url:"${pageContext.request.contextPath }/getUserById.action",
            data:{"id":id},
            success:function(data) {
                $("#userid").val(data.userid);
                $("#useracount").val(data.useracount);
                $("#password").val(data.password)
                $("#userrole").val(data.userrole)
                $("#userpower").val(data.userpower)
                $("#username").val(data.username);
                $("#age").val(data.age);
                $("#phone").val(data.phone);
                $("#address").val(data.address);
                $("#city").val(data.city);

            }
        });
    }
    // 执行修改客户操作
    function updateUser() {
        $.post("${pageContext.request.contextPath }/updateUser.action",$("#edit_user_form").serialize(),function(data){
            if(data =="OK"){
                alert("个人信息更新成功！");
                window.location.reload();
            }else{
                alert("个人信息更新失败！");
                window.location.reload();
            }
        });
    }
</script>
</body>
</html>